/* * Copyright 2024, T-Mobile * Package Name: kpi-media-metrics-1.0.0 * Commit Hash: fec2f9899377336728317308964229d0614f0190 * Build Date: Mon, 1 Jul 2024 22:29:52 GMT */ (()=>{"use strict";var e={924:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseKeyMap=t.trackingCookieKeyMap=t.UserType=t.Query_Parameters=t.environments=t.customEvents=t.phxBusConstants=t.windowVariables=t.webStorageVariables=t.common=void 0,t.common={TRACKING_COOKIE_NAME:"KPI_TA_Visit",DEFAULT_TIMER_INTERVAL:5e3,COOKIE_EXPIRATION_TIME:30,MAX_TIMECOUNT:300},t.webStorageVariables={LS_PAGE_VISITS_KEY:"KPI_Visited_Pages",CART_OPEN:"KPI_cartOpen",ADD_TO_CART:"KPI_productAddedToCart",TM_FLAG:"tmFlag"},t.windowVariables={DATALAYER_OBJECT:"digitalData",ADOBE_LAUNCH_OBJECT:"_satellite",ALLOY:"alloy",PHOENIX:"phoenix",MT_KPI_CDL:"cdl",TMO_ANALYTICS:"ta"},t.phxBusConstants={ADD_TO_CART_TOPIC:"ADD_TO_CART",ADD_TO_CART_CHANNEL:"ADD_TO_CART_CLICK",ANALYTICS_TOPIC:"ANALYTICS",ANALYTICS_CHANNEL:"FIRE",ANALYTICS_ADD_TO_CART_EVENT:"addToCart"},t.customEvents={MT_KPI_cdlPageLoadEvent:"cdlPageLoadEvent",MT_KPI_targetPageLoad:"TargetPageLoad",MT_KPI_TMOCartProductChanged:"TMOCartProductChanged"},function(e){e.TM_PROD_ENV="production"}(t.environments||(t.environments={})),function(e){e.TM_KEY="tm",e.TM_VALUE_YES="yes"}(t.Query_Parameters||(t.Query_Parameters={})),function(e){e.Customer="Customer",e.Prospect="Prospect"}(t.UserType||(t.UserType={})),t.trackingCookieKeyMap={global:"g","t-mobile":"g",metro:"g",timeSpentInVisit:"t",pageCountInVisit:"p",kpisFired:"kf",postpaid:"pp","postpaid-voice":"ppv","postpaid-internet":"ppi",prepaid:"pd","prepaid-connectbytmo":"pdc","postpaid-tfb":"ptf","postpaid-tfb-internet":"ptfi","postpaid-bizil":"pbz","postpaid-voice_pageview_spv":"ppv_spv","postpaid-voice_pageview_lowfunnel":"ppv_lf",tmo_funnel_top:"tft",tmo_funnel_top_be:"tft1",tmo_funnel_top_pe:"tft2",tmo_funnel_upp:"tfu",tmo_funnel_upp_be:"tfu1",tmo_funnel_upp_pe:"tfu2","postpaid-voice_spvplus":"ppv1","postpaid-voice_spvplus_pe":"ppv2","postpaid-voice_spv":"ppv3","postpaid-voice_spv_pe":"ppv4","postpaid-voice_action_cart":"ppv5","postpaid-voice_action_cart_pe":"ppv6","postpaid-voice_funnel_low":"ppvfl","postpaid-voice_funnel_low_pe":"ppvfl2","postpaid-voice_action_call":"ppv7","postpaid-voice_action_call_pe":"ppv8","postpaid-voice_lowfunnelpv":"ppv_lfpv1","postpaid-voice_lowfunnelpv_pe":"ppv_lfpv2"},t.reverseKeyMap={g:"global",t:"timeSpentInVisit",p:"pageCountInVisit",kf:"kpisFired",pp:"postpaid",ppv:"postpaid-voice",ppi:"postpaid-internet",pd:"prepaid",pdc:"prepaid-connectbytmo",ptf:"postpaid-tfb",ptfi:"postpaid-tfb-internet",pbz:"postpaid-bizil",ppv_spv:"postpaid-voice_pageview_spv",ppv_lf:"postpaid-voice_pageview_lowfunnel",tft:"tmo_funnel_top",tft1:"tmo_funnel_top_be",tft2:"tmo_funnel_top_pe",tfu:"tmo_funnel_upp",tfu1:"tmo_funnel_upp_be",tfu2:"tmo_funnel_upp_pe",ppv1:"postpaid-voice_spvplus",ppv2:"postpaid-voice_spvplus_pe",ppv3:"postpaid-voice_spv",ppv4:"postpaid-voice_spv_pe",ppv5:"postpaid-voice_action_cart",ppv6:"postpaid-voice_action_cart_pe",ppvfl:"postpaid-voice_funnel_low",ppvfl2:"postpaid-voice_funnel_low_pe",ppv7:"postpaid-voice_action_call",ppv8:"postpaid-voice_action_call_pe",ppv_lfpv1:"postpaid-voice_lowfunnelpv",ppv_lfpv2:"postpaid-voice_lowfunnelpv_pe"}},196:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shouldLog=t.getLogger=t.error=t.debug=void 0;const n=i(924),o=r("KPI_MA");function r(e){var t;return null===(t=window[n.windowVariables.ADOBE_LAUNCH_OBJECT].getVar("globalHelper"))||void 0===t?void 0:t.getLogger(e)}t.debug=function(...e){o.logd(...e)},t.error=function(...e){o.loge(...e)},t.getLogger=r,t.shouldLog=function(){var e;return null===(e=window[n.windowVariables.ADOBE_LAUNCH_OBJECT].getVar("globalHelper"))||void 0===e?void 0:e.isLogsOn}},125:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StorageManager=void 0;const n=i(196),o=i(633),r=i(924);class a{constructor(){this.trackingData={},this.cookieKeyName=r.common.TRACKING_COOKIE_NAME,this.trackingData=this.getTrackingCookie(this.cookieKeyName),this.triggeredEventList=[]}static getInstance(){return a.instance||(a.instance=new a),a.instance}setTrackingData(e){this.trackingData=e}getTrackingData(){return this.trackingData}addEventToList(e){this.triggeredEventList.push(e)}getEventList(){return this.triggeredEventList}clearEventList(){this.triggeredEventList=[]}getExpirationDate(){return this.expirationDate}updateExpirationDate(){const e=new Date;return e.setTime(e.getTime()+60*r.common.COOKIE_EXPIRATION_TIME*1e3),this.expirationDate=e.toUTCString(),this.expirationDate}setTimeTrackingFlag(e){this.trackTimeFlag=e}getTrackingCookie(e){const t=document.cookie.split("; ").find((t=>t.startsWith(`${e}=`)));return t?(this.trackingData=JSON.parse(decodeURIComponent(t.split("=")[1])),this.trackingData):null}updateOrCreateTrackingCookie(e){const t=this.getTrackingCookie(e);if(t)return n.debug("Tracking cookie already exists"),this.expirationDate=this.updateTrackingCookie(e,t),this.trackingData=t,t;{n.debug("Tracking cookie does not exist or has expired"),o.clearTrackingData();const t={g:this.trackTimeFlag?{t:0,p:0}:{p:0},kf:""},i=encodeURIComponent(JSON.stringify(t)),r=o.getDomainForCookie();return this.expirationDate=this.updateExpirationDate(),document.cookie=`${e}=${i}; expires=${this.expirationDate}; path=/; domain=${r}`,this.trackingData=t,t}}updateTrackingCookie(e,t,i){if(!t)return;i||(i=this.updateExpirationDate(),n.debug("Tracking cookie updated with new expiration time"));const r=o.getDomainForCookie();return document.cookie=`${e}=${encodeURIComponent(JSON.stringify(t))}; expires=${i}; path=/; domain=${r};`,this.trackingData=t,this.expirationDate=i,i}addFiredKPIToTrackingCookie(e){const t=this.getTrackingData();if(t){n.debug(e+" was fired!");const i=r.trackingCookieKeyMap[e]||e;t[r.trackingCookieKeyMap.kpisFired]=this.appendToKpiFired(t[r.trackingCookieKeyMap.kpisFired],i);const a=o.getUserType()===r.UserType.Customer?"be":"pe",s=r.trackingCookieKeyMap[e+"_"+a]||e+"_"+a;t[r.trackingCookieKeyMap.kpisFired]=this.appendToKpiFired(t[r.trackingCookieKeyMap.kpisFired],s),this.updateTrackingCookie(this.cookieKeyName,t)}}appendToKpiFired(e,t){return e?`${e}.${t}`:t}checkIfKPIHasFired(e){var t;const i=null===(t=this.trackingData)||void 0===t?void 0:t[r.trackingCookieKeyMap.kpisFired],n=r.trackingCookieKeyMap[e];return!(!i||!n)&&i.split(".").includes(n)}clear(){this.trackingData={}}}t.StorageManager=a},794:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeManager=void 0;const n=i(924);class o{constructor(){this.startTime=Date.now(),this.timerInterval=n.common.DEFAULT_TIMER_INTERVAL,this.intervalId=null}static getInstance(){return o.instance||(o.instance=new o),o.instance}getStartTime(){return this.startTime}setStartTime(e){this.startTime=e}setTimerInterval(e){this.timerInterval=e}startTimer(e){null===this.intervalId&&(this.intervalId=window.setInterval(e,this.timerInterval))}stopTimer(){null!==this.intervalId&&(window.clearInterval(this.intervalId),this.intervalId=null)}calculateTimeSpent(){const e=Date.now()-this.startTime;return Math.round(e/1e3)}}t.TimeManager=o},633:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDomainForCookie=t.isInvocaPhoneNumber=t.clearTrackingData=t.triggerEvent=t.sendAdobeEvent=t.getUserType=t.getDataLayer=t.isCDLAvailable=t.isPhoenixPage=void 0;const n=i(196),o=i(924);function r(){return window[o.windowVariables.MT_KPI_CDL]}function a(){return window[o.windowVariables.DATALAYER_OBJECT]}t.isPhoenixPage=function(){return void 0!==window[o.windowVariables.PHOENIX]},t.isCDLAvailable=r,t.getDataLayer=a,t.getUserType=function(){var e,t,i,s;try{let n=o.UserType.Prospect;const c=a();if(r()){n=(null===(e=null==c?void 0:c.user)||void 0===e?void 0:e.userType).trim().toLowerCase()===o.UserType.Customer.toLowerCase()?o.UserType.Customer:o.UserType.Prospect}else window[o.windowVariables.TMO_ANALYTICS]&&"function"!=typeof window[o.windowVariables.TMO_ANALYTICS].isCustomer?n=(null===(i=null===(t=window[o.windowVariables.TMO_ANALYTICS].common)||void 0===t?void 0:t.service)||void 0===i?void 0:i.isKnownUser())?o.UserType.Customer:o.UserType.Prospect:(null===(s=window[o.windowVariables.TMO_ANALYTICS])||void 0===s?void 0:s.isCustomer)&&(n=window[o.windowVariables.TMO_ANALYTICS].isCustomer()?o.UserType.Customer:o.UserType.Prospect);return n}catch(e){return n.debug("isUserProspect err:",e),o.UserType.Prospect}},t.sendAdobeEvent=function(e,t,i,n){window.s&&(window.s.linkTrackVars="events,pageName,eVar5,prop35",window.s.events=t,window.s.linkTrackEvents=t,window.s.prop35=i,window.s.prop72=n,window.s.tl(this,"o",e))},t.triggerEvent=function(e,t){let i;"function"==typeof window.CustomEvent?i=new CustomEvent(e,{detail:t}):"function"==typeof window.Event&&(i=new Event(e)),i?window.dispatchEvent(i):n.debug("triggerEvent(): browser does not support custom event. agent= "+navigator.userAgent)},t.clearTrackingData=function(){window.localStorage.removeItem(o.webStorageVariables.LS_PAGE_VISITS_KEY),window.sessionStorage.removeItem(o.webStorageVariables.CART_OPEN),window.sessionStorage.removeItem(o.webStorageVariables.ADD_TO_CART)},t.isInvocaPhoneNumber=function(e){var t,i,n,o;let r=!1;if(window.Invoca&&(null===(t=window.Invoca)||void 0===t?void 0:t.PNAPI)&&(null===(n=null===(i=window.Invoca)||void 0===i?void 0:i.PNAPI)||void 0===n?void 0:n.placements))for(const t of window.Invoca.PNAPI.placements())if(e==(null===(o=t.invocaNumber)||void 0===o?void 0:o.number)){r=!0;break}return r},t.getDomainForCookie=function(){return window.location.hostname.includes(".metrobyt-mobile.com")?".metrobyt-mobile.com":".t-mobile.com"}},425:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.promiseConditionCheckers=t.booleanConditionCheckers=void 0;const n=i(924),o=i(633),r=i(196),a=i(125);t.booleanConditionCheckers={pageCount:e=>{if(!e.pageLabel||!e.minPageCount)return r.debug("Parameters missing for page count condition"),!1;const t=a.StorageManager.getInstance().getTrackingData(),i=n.trackingCookieKeyMap.pageCountInVisit,o=n.trackingCookieKeyMap[e.pageLabel];return!!(t&&o&&t[o]&&t[o][i]>=parseInt(e.minPageCount))},cartOpenCondition:e=>{if(!e.pathname)return r.debug("Parameters missing for cart open condition"),!1;return!!(window.location.pathname===e.pathname)},timeCountCondition:e=>{if(!e.pageLabel||!e.minTimeCount)return r.debug("Parameters missing for time count condition"),!1;const t=a.StorageManager.getInstance().getTrackingCookie(n.common.TRACKING_COOKIE_NAME),i=n.trackingCookieKeyMap[e.pageLabel];return!!(t&&i&&t[i]&&t[i][n.trackingCookieKeyMap.timeSpentInVisit]>=parseInt(e.minTimeCount))},kpiFired:e=>!(!e.kpiDependencyName||!a.StorageManager.getInstance().checkIfKPIHasFired(e.kpiDependencyName)),checkLocalStorageCondition:e=>{if(!e.keyName)return!1;return null!==localStorage.getItem(e.keyName)}},t.promiseConditionCheckers={elementIdClickCondition:e=>{if(!e||!e.elementID)throw new Error("Parameter 'elementID' is required but was not provided.");return new Promise((t=>{const i=document.getElementById(e.elementID);null==i||i.addEventListener("click",(()=>t(!0)),{once:!0})}))},addToCartCondition:()=>new Promise((e=>{var t,i;if(o.isPhoenixPage()){const o=null===(i=null===(t=window.phoenix)||void 0===t?void 0:t.bus)||void 0===i?void 0:i.subscribe(n.phxBusConstants.ANALYTICS_TOPIC,n.phxBusConstants.ANALYTICS_CHANNEL,(t=>{var i;r.debug("ANALYTICS FIRE"),r.debug(t.payload),n.phxBusConstants.ANALYTICS_ADD_TO_CART_EVENT===(null===(i=null==t?void 0:t.payload)||void 0===i?void 0:i.analyticsEvent)&&(r.debug("Analytics Queue Item added to cart"),e(!0),o())}))}else o.isPhoenixPage()||o.isCDLAvailable()||window.addEventListener(n.customEvents.MT_KPI_TMOCartProductChanged,(()=>{r.debug("Item added to cart on non-phoenix page"),e(!0)}),{once:!0})})),telephoneNumberClickCondition:()=>new Promise((e=>{const t=document.querySelectorAll('a[href^="tel:"]');function i(n){r.debug("Tel Number link clicked");const a=this.href.replace("tel:","");o.isInvocaPhoneNumber(a)?(null==t||t.forEach((e=>{e.removeEventListener("click",i)})),e(!0)):r.debug(`${a} is not an Invoca phone number`)}null==t||t.forEach((e=>{e.addEventListener("click",i,{once:!0})}))})),eventTriggerCondition:e=>{if(!e||!e.eventName)throw new Error("Parameter 'eventName' is required but was not provided.");return new Promise((t=>{a.StorageManager.getInstance().getEventList().includes(e.eventName)?(r.debug(`${e.eventName} has already been triggered`),t(!0)):window.addEventListener(e.eventName,(()=>t(!0)),{once:!0})}))}}},736:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KpiMediaManager=void 0;const n=i(924),o=i(633),r=i(196),a=i(794),s=i(125),c=i(425),p=i(521);t.KpiMediaManager=class{constructor(){var e,t,i,o;r.debug("KPI Media Analytics running"),this.satellite=window[n.windowVariables.ADOBE_LAUNCH_OBJECT],this.kpi_data_lookup_urls=null===(e=this.satellite.getVar("kpi_data_lookup"))||void 0===e?void 0:e.mappings,this.kpi_excluded_urls=this.satellite.getVar("kpi_url_exclusions"),this.kpi_config=this.satellite.getVar("kpi_config"),this.trackTimeFlag="true"===(null===(t=this.kpi_config)||void 0===t?void 0:t.trackTime),this.kpis=[],this.timeManager=a.TimeManager.getInstance(),this.storageManager=s.StorageManager.getInstance(),this.storageManager.setTimeTrackingFlag(this.trackTimeFlag),this.stagingFlag=(null===(o=null===(i=this.satellite)||void 0===i?void 0:i.environment)||void 0===o?void 0:o.stage)!==n.environments.TM_PROD_ENV}destroyKPIs(){this.kpis&&this.kpis.length>0&&(this.kpis.forEach((e=>{e.cleanupKPI()})),this.kpis=[])}initiateApp(){o.isCDLAvailable()?(window[n.customEvents.MT_KPI_cdlPageLoadEvent]?this.initiateAllKPIs():r.debug("KPI Media Analytics waiting for cdlPageLoadEvent"),window.addEventListener(n.customEvents.MT_KPI_cdlPageLoadEvent,function(){r.debug("cdlPageLoadEvent called"),this.destroyKPIs(),this.initiateAllKPIs()}.bind(this))):(this.initiateAllKPIs(),window.addEventListener(n.customEvents.MT_KPI_targetPageLoad,function(){this.destroyKPIs(),this.initiateAllKPIs()}.bind(this)))}setupKPIs(){var e,t,i,n,a;if(this.userType=o.getUserType(),this.kpi_config&&this.kpi_config.kpis)for(const o of this.kpi_config.kpis){if("all"!=o.audience.toLowerCase()&&o.audience.toLowerCase()!=this.userType.toLowerCase()){r.debug(`Wrong user type for ${o.name}`);continue}if(o.pageLabel&&this.cachedMostSpecificMatch&&!(null===(t=null===(e=this.cachedMostSpecificMatch)||void 0===e?void 0:e.labels)||void 0===t?void 0:t.m_lblpg_lob.includes(o.pageLabel))&&!(null===(n=null===(i=this.cachedMostSpecificMatch)||void 0===i?void 0:i.labels)||void 0===n?void 0:n.m_lblpg_kpi.includes(o.pageLabel))){r.debug(`Wrong page label for ${o.name}`);continue}let s=!0;if((null===(a=o.preConditions)||void 0===a?void 0:a.length)>=1&&(s=this.checkPreConditions(o.preConditions)),!s){r.debug(`Preconditions not met for ${o.name}`);continue}const c=new p.KPI(o);c.hasAlreadyFired()?r.debug(`Skipping ${o.name} KPI since it has already fired.`):(r.debug(`Adding KPI to page: ${o.name}`),this.kpis.push(c))}}checkPreConditions(e){let t=!0;for(const i of e){if("boolean"!=i.returnType){t=!1;break}const e=c.booleanConditionCheckers[i.type];if(e&&(t=e(i.parameters),!t))break}return t}initiateAllKPIs(){this.timeManager.setStartTime(Date.now()),this.storageManager.clearEventList(),this.cachedMostSpecificMatch=null,this.processCurrentURL(),this.setupKPIs(),this.trackTimeFlag&&(document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState?(this.timeManager.stopTimer(),this.updateTimeSpentInVisit.bind(this)()):(this.timeManager.setStartTime(Date.now()),this.timeManager.startTimer(this.updateTimeSpentInVisit.bind(this)))})),this.timeManager.startTimer(this.updateTimeSpentInVisit.bind(this))),this.kpis.forEach((e=>{e.init()}))}shouldTrackInStaging(){if(this.stagingFlag){return new URLSearchParams(window.location.search).get(n.Query_Parameters.TM_KEY)===n.Query_Parameters.TM_VALUE_YES||window.sessionStorage.getItem(n.webStorageVariables.TM_FLAG)===n.Query_Parameters.TM_VALUE_YES||(r.debug("Not configured to track KPI media metrics in staging"),!1)}}findMostSpecificURLMatch(e,t,i){if(i.some((t=>e.includes(t))))return null;if(null!==this.cachedMostSpecificMatch)return this.cachedMostSpecificMatch;let n,o=0;e:for(const i of t)for(const t of i.url)if(i.matchrule&&"equal"==i.matchrule){if(e==t){r.debug("Exact Match: "+t),n=i;break e}}else e.includes(t)&&t.length>o&&(n=i,o=t.length);return this.cachedMostSpecificMatch=n,n}updateTimeSpentInVisit(){const e=this.storageManager.getTrackingCookie(n.common.TRACKING_COOKIE_NAME);if(!e)return;const t=this.timeManager.calculateTimeSpent();this.cachedMostSpecificMatch&&(e.g&&e.g.t+t<=n.common.MAX_TIMECOUNT&&(e.g.t+=t),this.cachedMostSpecificMatch.labels.m_lblpg_lob.forEach((i=>{e[n.trackingCookieKeyMap[i]]&&e[n.trackingCookieKeyMap[i]].t+t<=n.common.MAX_TIMECOUNT&&(e[n.trackingCookieKeyMap[i]].t+=t)})),this.cachedMostSpecificMatch.labels.m_lblpg_kpi.forEach((i=>{e[n.trackingCookieKeyMap[i]]&&e[n.trackingCookieKeyMap[i]].t+t<=n.common.MAX_TIMECOUNT&&(e[n.trackingCookieKeyMap[i]].t+=t)})),this.storageManager.updateTrackingCookie(n.common.TRACKING_COOKIE_NAME,e,this.storageManager.getExpirationDate()),this.timeManager.setStartTime(Date.now()))}processCurrentURL(){const e=window.location.hostname,t=window.location.pathname;let i=e+(t&&"/"!==t?t:"");this.shouldTrackInStaging()&&i.includes("staging.")&&(i=i.replace("staging.","www."));const o=this.storageManager.updateOrCreateTrackingCookie(n.common.TRACKING_COOKIE_NAME),a=this.findMostSpecificURLMatch(i,this.kpi_data_lookup_urls,this.kpi_excluded_urls);if(r.debug("mostSpecificMatch: "),r.debug(a),a){const e=JSON.parse(localStorage.getItem(n.webStorageVariables.LS_PAGE_VISITS_KEY)||"[]");let t=!1;e.includes(i)?r.debug("Page already visited: "+i):(e.push(i),localStorage.setItem(n.webStorageVariables.LS_PAGE_VISITS_KEY,JSON.stringify(e)),t=!0,o.g.p+=1);const s=this.trackTimeFlag?{t:0,p:0}:{p:0};a.labels.m_lblpg_lob.forEach((e=>{o[n.trackingCookieKeyMap[e]]||(o[n.trackingCookieKeyMap[e]]=Object.assign({},s)),t&&(o[n.trackingCookieKeyMap[e]].p+=1)})),a.labels.m_lblpg_kpi.forEach((e=>{o[n.trackingCookieKeyMap[e]]||(o[n.trackingCookieKeyMap[e]]=Object.assign({},s)),t&&(o[n.trackingCookieKeyMap[e]].p+=1)})),this.storageManager.updateTrackingCookie(n.common.TRACKING_COOKIE_NAME,o,this.storageManager.getExpirationDate())}else r.debug("mostSpecificMatch not found or already cached: "),r.debug(a)}}},521:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KPI=void 0;const n=i(582),o=i(196),r=i(633),a=i(924),s=i(125),c=i(425);t.KPI=class{constructor(e){this.name=e.name,this.eventName=e.triggerDetails.eventName,this.config=e,this.conditionMet="",this.booleanConditions=[],this.promiseConditions=[];for(const t of e.conditions)if("boolean"===t.returnType){const e={name:"",parameters:void 0,check:void 0};if(e.name=t.name,e.parameters=t.parameters,e.check=c.booleanConditionCheckers[t.type],!e.check){o.debug(`No check function found for ${e.name}`);continue}this.booleanConditions.push(e)}else{if("promise"!==t.returnType){o.error("Condition returnType not recognized for "+this.name+": "+t.returnType);continue}{const e={name:"",parameters:void 0,check:void 0};e.name=t.name,e.parameters=t.parameters,e.check=c.promiseConditionCheckers[t.type],this.promiseConditions.push(e)}}}init(){this.hasAlreadyFired()||this.checkIfAnyConditionsMet()}checkIfAnyConditionsMet(){return n.__awaiter(this,void 0,void 0,(function*(){for(const e of this.booleanConditions)if(e.check(e.parameters))return o.debug(`Triggering KPI: ${this.name} for ${e.name}`),this.conditionMet=e.name,this.triggerKPI(this.conditionMet),!0;try{yield Promise.race(this.promiseConditions.map((e=>e.check(e.parameters).then((t=>{if(t)throw this.conditionMet=e.name,"trigger";return!1})))));o.debug(`No conditions met for KPI: ${this.name}`)}catch(e){if("trigger"===e)return o.debug(`Triggering KPI: ${this.name} for ${this.conditionMet}`),this.triggerKPI(this.conditionMet),!0;o.error(`Error evaluating KPI: ${this.name}`,e)}return!1}))}hasAlreadyFired(){return s.StorageManager.getInstance().checkIfKPIHasFired(this.name)}triggerKPI(e){if(!this.hasAlreadyFired()){if("event"===this.config.triggerDetails.type&&this.eventName&&(r.triggerEvent(this.eventName),s.StorageManager.getInstance().addEventToList(this.eventName),"true"===this.config.triggerDetails.includeUserTypeEvent)){const e=r.getUserType()==a.UserType.Customer?"B":"P",t=this.eventName+"_"+e;r.triggerEvent(t),s.StorageManager.getInstance().addEventToList(t)}s.StorageManager.getInstance().addFiredKPIToTrackingCookie(this.name),this.conditionMet&&s.StorageManager.getInstance().addFiredKPIToTrackingCookie(this.conditionMet)}}cleanupKPI(){}}},219:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(736);class o extends n.KpiMediaManager{constructor(){super()}}t.default=o},582:(e,t,i)=>{i.r(t),i.d(t,{__addDisposableResource:()=>D,__assign:()=>r,__asyncDelegator:()=>I,__asyncGenerator:()=>C,__asyncValues:()=>P,__await:()=>k,__awaiter:()=>f,__classPrivateFieldGet:()=>O,__classPrivateFieldIn:()=>L,__classPrivateFieldSet:()=>K,__createBinding:()=>h,__decorate:()=>s,__disposeResources:()=>x,__esDecorate:()=>p,__exportStar:()=>v,__extends:()=>o,__generator:()=>_,__importDefault:()=>S,__importStar:()=>A,__makeTemplateObject:()=>M,__metadata:()=>g,__param:()=>c,__propKey:()=>d,__read:()=>y,__rest:()=>a,__runInitializers:()=>l,__setFunctionName:()=>u,__spread:()=>b,__spreadArray:()=>T,__spreadArrays:()=>w,__values:()=>m,default:()=>V});var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var r=function(){return r=Object.assign||function(e){for(var t,i=1,n=arguments.length;i=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a}function c(e,t){return function(i,n){t(i,n,e)}}function p(e,t,i,n,o,r){function a(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var s,c=n.kind,p="getter"===c?"get":"setter"===c?"set":"value",l=!t&&e?n.static?e:e.prototype:null,d=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),u=!1,g=i.length-1;g>=0;g--){var f={};for(var _ in n)f[_]="access"===_?{}:n[_];for(var _ in n.access)f.access[_]=n.access[_];f.addInitializer=function(e){if(u)throw new TypeError("Cannot add initializers after decoration has completed");r.push(a(e||null))};var h=(0,i[g])("accessor"===c?{get:d.get,set:d.set}:d[p],f);if("accessor"===c){if(void 0===h)continue;if(null===h||"object"!=typeof h)throw new TypeError("Object expected");(s=a(h.get))&&(d.get=s),(s=a(h.set))&&(d.set=s),(s=a(h.init))&&o.unshift(s)}else(s=a(h))&&("field"===c?o.unshift(s):d[p]=s)}l&&Object.defineProperty(l,n.name,d),u=!0}function l(e,t,i){for(var n=arguments.length>2,o=0;o0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,o,r=i.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=r.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return a}function b(){for(var e=[],t=0;t1||s(e,t)}))},t&&(n[e]=t(n[e])))}function s(e,t){try{(i=o[e](t)).value instanceof k?Promise.resolve(i.value.v).then(c,p):l(r[0][2],i)}catch(e){l(r[0][3],e)}var i}function c(e){s("next",e)}function p(e){s("throw",e)}function l(e,t){e(t),r.shift(),r.length&&s(r[0][0],r[0][1])}}function I(e){var t,i;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(i=!i)?{value:k(e[n](t)),done:!1}:o?o(t):t}:o}}function P(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,i=e[Symbol.asyncIterator];return i?i.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=e[i]&&function(t){return new Promise((function(n,o){(function(e,t,i,n){Promise.resolve(n).then((function(t){e({value:t,done:i})}),t)})(n,o,(t=e[i](t)).done,t.value)}))}}}function M(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var E=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function A(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&h(t,e,i);return E(t,e),t}function S(e){return e&&e.__esModule?e:{default:e}}function O(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function K(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}function L(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function D(e,t,i){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,o;if(i){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],i&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:i})}else i&&e.stack.push({async:!0});return t}var N="function"==typeof SuppressedError?SuppressedError:function(e,t,i){var n=new Error(i);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function x(e){function t(t){e.error=e.hasError?new N(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function i(){for(;e.stack.length;){var n=e.stack.pop();try{var o=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(o).then(i,(function(e){return t(e),i()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}const V={__extends:o,__assign:r,__rest:a,__decorate:s,__param:c,__metadata:g,__awaiter:f,__generator:_,__createBinding:h,__exportStar:v,__values:m,__read:y,__spread:b,__spreadArrays:w,__spreadArray:T,__await:k,__asyncGenerator:C,__asyncDelegator:I,__asyncValues:P,__makeTemplateObject:M,__importStar:A,__importDefault:S,__classPrivateFieldGet:O,__classPrivateFieldSet:K,__classPrivateFieldIn:L,__addDisposableResource:D,__disposeResources:x}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};(new(i(219).default)).initiateApp()})();